﻿using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

namespace SG3L_RAG.UnitTests;

/// <summary>
/// 整体测试运行状态和环境验证
/// </summary>
public class TestEnvironmentTests
{
    private readonly ITestOutputHelper _output;

    public TestEnvironmentTests(ITestOutputHelper output)
    {
        _output = output;
    }

    [Fact]
    public void TestEnvironment_ShouldBeConfiguredCorrectly()
    {
        // Arrange & Act
        var testAssembly = typeof(TestEnvironmentTests).Assembly;
        var testClasses = testAssembly.GetTypes()
            .Where(t => t.Name.EndsWith("Tests") && t != typeof(TestEnvironmentTests))
            .ToList();

        // Assert
        testClasses.Should().NotBeEmpty("测试类应该存在");
        _output.WriteLine($"发现 {testClasses.Count} 个测试类:");
        
        foreach (var testClass in testClasses)
        {
            _output.WriteLine($"- {testClass.Name}");
        }
    }

    [Fact]
    public void DateTime_UtcNow_ShouldBeWithinReasonableRange()
    {
        // Arrange
        var beforeTest = DateTime.UtcNow;
        
        // Act
        var testTime = DateTime.UtcNow;
        
        // Assert
        testTime.Should().BeOnOrAfter(beforeTest);
        testTime.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(1));
    }

    [Fact]
    public void Guid_NewGuid_ShouldGenerateUniqueIds()
    {
        // Arrange & Act
        var id1 = Guid.NewGuid();
        var id2 = Guid.NewGuid();
        var id3 = Guid.NewGuid();

        // Assert
        id1.Should().NotBe(id2);
        id2.Should().NotBe(id3);
        id1.Should().NotBe(id3);
        
        id1.Should().NotBeEmpty();
        id2.Should().NotBeEmpty();
        id3.Should().NotBeEmpty();
    }

    [Theory]
    [InlineData("测试数据1")]
    [InlineData("TestData2")]
    [InlineData("数据测试3")]
    public void String_Comparison_ShouldWorkWithUnicodeCharacters(string testString)
    {
        // Arrange & Act
        var result = testString.Length > 0;

        // Assert
        result.Should().BeTrue();
        testString.Should().NotBeNullOrEmpty();
        _output.WriteLine($"测试字符串: {testString}, 长度: {testString.Length}");
    }
}
